package project.teg.configuration;

import project.teg.common.types.HandlingType;
import project.teg.common.types.DBPreviewType;
import project.teg.common.types.DeviceType;
import android.content.Context;
import android.content.SharedPreferences;
import android.graphics.Point;
import android.preference.PreferenceManager;
import android.view.Display;

public class Global {

	public static void GetAllValues(Context context) {

		SharedPreferences app_preferences = PreferenceManager
				.getDefaultSharedPreferences(context);

		showChronometer = app_preferences.getBoolean("showChronometer", true);
		showLevel = app_preferences.getBoolean("showLevel", true);
		showScore = app_preferences.getBoolean("showScore", true);
		showDescription = app_preferences.getBoolean("showDescription", true);
		maxLevels = app_preferences.getInt("maxLevels", 15);

		int deviceTypeKey = app_preferences.getInt("deviceType", 0);
		switch (deviceTypeKey) {
		case 0:
			deviceType = DeviceType.Mouse;
			break;
		case 1:
			deviceType = DeviceType.TouchScreen;
			break;
		case 2:
			deviceType = DeviceType.MobileDevice;
			break;
		default:
			break;
		}

		int handlingTypeKey = app_preferences.getInt("handlingType", 0);
		switch (handlingTypeKey) {
		case 0:
			handlingType = HandlingType.OneHolding_and_Operating;
			break;
		case 1:
			handlingType = HandlingType.OneHolding_OneOperating;
			break;
		case 2:
			handlingType = HandlingType.TwoHoldind_and_Operating;
			break;
		default:
			break;
		}
	}

	public static void SeveAllValues(Context context) {

		SharedPreferences app_preferences = PreferenceManager
				.getDefaultSharedPreferences(context);

		SharedPreferences.Editor editor = app_preferences.edit();
		editor.putBoolean("showChronometer", showChronometer);
		editor.putBoolean("showLevel", showLevel);
		editor.putBoolean("showScore", showScore);
		editor.putBoolean("showDescription", showDescription);
		editor.putInt("maxLevels", maxLevels);
		editor.putInt("deviceType", deviceType.ordinal());
		editor.putInt("handlingType", handlingType.ordinal());
		editor.commit();
	}

	public static DeviceType deviceType;

	public static HandlingType handlingType;

	public static boolean showChronometer;

	public static boolean showLevel;

	public static boolean showScore;

	public static boolean showDescription;

	public static int maxLevels;

	// new
	public static int dpi = 240;

	public static Point screenSizePx = new Point(480, 800);

	// pregled baze:
	public static DBPreviewType DBPreviewType;

}
